﻿#pragma once
#include "../logdef.h"
#include "../logger.h"

#include <ctime>
#include <stdio.h>
#include <stdarg.h>
#include <thread>
#include <chrono>
#include <algorithm>
#include <iomanip>
#include <ctime>

using str_t = std::string;
using atm_bool_t = std::atomic_bool;


NAMESPACE_BEG


struct LogProper
{
    LogProper(LOG_LEVEL level,const char* file, const char* fun, int line) :level_(level), file_(file), func_(fun), line_(line),
        time_(std::chrono::high_resolution_clock::now()) {
        std::stringstream ss;
        ss << std::this_thread::get_id();
        thread_id_ = std::atoll(ss.str().c_str());
    }


    LogProper() :
        time_(std::chrono::high_resolution_clock::now()) {
        std::stringstream ss;
        ss << std::this_thread::get_id();
        thread_id_ = std::atoll(ss.str().c_str());
    }
    const char* file_;
    const char* func_;
    LOG_LEVEL   level_;
    int64_t     line_=0;
    std::chrono::high_resolution_clock::time_point time_;
    uint64_t    thread_id_=0;

};

struct LogItem {
    LogProper    property_;
    std::string  log_;
};


class LoggerBase {
public:
    explicit LoggerBase(LOG_LEVEL level) :level_(level), thread_id_(std::this_thread::get_id()) {
    }
    ~LoggerBase() {}

    virtual void send(LogItem&& item) = 0;
protected:
    std::thread::id thread_id_;
    LOG_LEVEL level_;

};


NAMESPACE_END
